package com.tarry.shop.search.repository;

import com.tarry.shop.search.domain.dto.GoodsDTO;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

public interface GoodsRepository extends ElasticsearchRepository<GoodsDTO,Integer> {

    @Highlight(
            fields = {@HighlightField(name = "goodsName")},
            parameters = @HighlightParameters(preTags = {"<span style='color:red'>"},
                    postTags = {"</span>"}, numberOfFragments = 0))
    List<SearchHit<GoodsDTO>> findGoodsDTOByGoodsName(String goodsName);
}
